package com.fts.admin.record.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fts.admin.record.entity.dto.RecordDTO;
import com.fts.admin.record.entity.vo.RecordVO;
import com.fts.admin.record.service.RecordService;
import com.fts.common.query.BaseQuery;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author lzt
 * @date 2023/11/21 21:51
 */
@RestController
@RequestMapping("/recordController")
@Api(tags = "笔记")
public class RecordController {

    @Resource
    RecordService recordService;

    @Operation(summary = "保存")
    @PostMapping("/save")
    public RecordVO save(@Parameter(description = "笔记入参") @RequestBody RecordDTO recordDTO){
        return recordService.save(recordDTO);
    }

    @Operation(summary = "删除")
    @GetMapping("/delete")
    public boolean delete(@RequestParam("id") Long id){
        return recordService.delete(id);
    }

    @Operation(summary = "分页查询")
    @PostMapping("/getPage")
    public IPage<RecordVO> getPage(@Validated BaseQuery baseQuery){
        return recordService.getPage(baseQuery);
    }
}
